<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <h2><c:out value="${season.name}"/></h2>
        <div class="colmask threecol">
            <div class="colmid">
                <div class="colleft">
                    <div class="col1" >
                        <h1>Score</h1>
                        <table class="simple">
                            <tr>
                                <td>Victory condition</td>
                                <td><c:out value="${season.victoryCondition}"/></td>
                            </tr>
                            <tr>
                                <td>Points for win</td>
                                <td><c:out value="${season.pointsForWin}"/></td>
                            </tr>
                            <tr>
                                <td>Points for draw</td>
                                <td><c:out value="${season.pointsForDraw}"/></td>
                            </tr>
                            <tr>
                                <td>Points for lose</td>
                                <td><c:out value="${season.pointsForLose}"/></td>
                            </tr>
                        </table>
                    </div>
                    <div class="col2">
                        <h1>Basic info</h1>
                        <table class="simple">
                            <tr>
                                <td>Name</td>
                                <td><c:out value="${season.name}"/></td>
                            </tr>
                            <tr>
                                <td>Start date</td>
                                <td><c:out value="${season.startDate}"/></td>
                            </tr>
                            <tr>
                                <td>End date</td>
                                <td><c:out value="${season.endDate}"/></td>
                            </tr>
                        </table>
                    </div>
                    <div class="col3">
                        <h1>Admission</h1>
                        <table class="simple">
                            <tr>
                                <td>Price [Kč]</td>
                                <td><c:out value="${season.admissionPrice}"/></td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div id="footer">
			<h1>Score</h1>
			<table class="default">
                <tr>
                    <th>Player</th>
                    <th>Score</th>
                </tr>
                <c:forEach  items="${persons}" var="player">
                    <tr>
                        <td><a href="<c:url value="/admin/person/detail?id=${player.id}" />"><c:out value="${player.firstName}"/> <c:out value="${player.lastName}"/></a></td>
                        <td><c:out value="${player.score}"/></td>
                    </tr>
                </c:forEach>
            </table>
			
            <h1>Matches</h1>
            <table class="default">
                <tr>
                    <th>Player1 vs Player 2</th>
                    <th>Date</th>
                    <th>Final Score</th>
                    <th>Detail</th>
                        <c:if test='<%= (Boolean.parseBoolean(session.getAttribute("isAdmin").toString()))%>' >
                        <th>Edit</th>
                        <th>Remove</th>
                        </c:if>
                </tr>
                <c:forEach  items="${matches}" var="match">
                    <tr>
                        <td><a href="<c:url value="/admin/match/detail?id=${match.id}" />"><c:out value="${match.player1FirstName}"/> <c:out value="${match.player1LastName}"/> - <c:out value="${match.player2FirstName}"/> <c:out value="${match.player2LastName}"/></a></td>
                        <td><c:out value="${match.dateAndTime}"/></td>
                        <td><c:out value="${match.finalScore}"/></td>
                        <td><a href="<c:url value="/admin/match/detail?id=${match.id}" />"><img src="<c:url value="/resources/img/detail-icon.png" />" width="16" height="16" alt="detail" /></a></td>
                                <c:if test='<%= (Boolean.parseBoolean(session.getAttribute("isAdmin").toString()))%>' >
                            <td><a href="<c:url value="/admin/match/edit?id=${match.id}&seasonId=${season.id}" />"><img src="<c:url value="/resources/img/edit-icon.gif" />" width="16" height="16" alt="edit" /></a></td>
                            <td><a href="<c:url value="/admin/match/remove?id=${match.id}&seasonId=${season.id}" />"><img src="<c:url value="/resources/img/remove-icon.gif" />" width="16" height="16" alt="remove" /></a></td>
                                </c:if>
                    </tr>
                </c:forEach>

            </table>
            <br/>
            <c:if test='<%= (Boolean.parseBoolean(session.getAttribute("isAdmin").toString()))%>' >
                <div class="buttons">
                    <a href="<c:url value="/admin/match/edit?id=-1&seasonId=${season.id}" />" class="button add">Add a new match</a>
                </div>
            </c:if>
        </div>
    </body>
</html>
